///////////////
//  by 辜勇胜 //
///////////////
#include <WiFi.h>
#include <WiFiAP.h>
#include "step_motor.h"
#include "camera_config.h"
#include "web_server.h"
#include "motor.h"

WiFiAPClass WiFiAP;
// wifi名称
const char* ssid = "GLL";//"ChinaNet-adbn";
// wifi密码
const char* password = "uusgf9vt";

// Set your Static IP address
IPAddress local_IP(192, 168, 1, 1);
// Set your Gateway IP address
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional

void setup() {


  // put your setup code here, to run once:
  Serial.begin(115200);


  // 初始化步进电机
  step_motor_init();
  // 小车马达初始化
  car_init();
  // 初始化摄像头
  camera_init();
  //
  //  if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
  //    Serial.println("STA Failed to configure");
  //  }
  //  // 连接wifi
  //  WiFi.begin(ssid, password);

  //  while (WiFi.status() != WL_CONNECTED) {
  //    delay(500);
  //    Serial.print(".");
  //  }
  //  Serial.println("");
  //  Serial.println("WiFi connected");

  //AP模式
  if (!WiFiAP.softAPConfig(local_IP, gateway, subnet)) {
    Serial.println("AP Failed to configure");
  }
  WiFiAP.softAP(ssid, password);
  Serial.println("Hotpot started");
  // 启动服务器
  startServer();

  Serial.print("Camera Ready! Use 'http://");
  //  Serial.print(WiFi.localIP());
  Serial.print("192, 168, 1, 1");
  Serial.println("' to connect");
}

void loop() {
  // put your main code here, to run repeatedly:

}
